<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div v-if="isLogin">
        <input type="text" placeholder="员工姓名" v-model="name">
        <input type="button" value="添加" @click="add()">
        <a href="javascript:void(0)" @click="dislogin()">退出登录</a>
    </div>
    <div v-else>
        <a href="">刷新</a>
        <a href="javascript:void(0)" @click="login()">登录</a>
    </div>
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th v-if="isLogin">操作</th>
        </tr>
        <tr v-for=" (name,i) in arr">
            <td>{{i+1}}</td>
            <td>{{name}}</td>
            <td v-if="isLogin"><a href="javascript:void (0)" @click="del(i)">删除</a></td>
        </tr>

    </table>

</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            isLogin : false,
            arr:[],
            name:""
        },
        methods:{
            add(){
                v.arr.push(v.name)
            },
            del(i){
                v.arr.splice(i,1);
            },
            login(){
              v.isLogin = true;
            },
            dislogin() {
                v.isLogin = false;
            }
        }
    })
</script>
</body>
</html>